package edu.nf.controller.admin;

import edu.nf.controller.BaseController;
import edu.nf.hotel.admin.AdminLoginService;
import edu.nf.hotel.admin.AdminUser;
import edu.nf.hotel.admin.impl.AdminLoginServiceImpl;
import org.nf.web.annotation.RequestMapping;
import org.nf.web.annotation.RequestParam;
import org.nf.web.servlet.View;
import org.nf.web.servlet.view.JsonView;

import javax.servlet.http.HttpSession;

/**
 * @Date 2023-06-16
 * @Author 陈
 */
public class AdminLoginController extends BaseController {
    /**
     * 管理员登录
     * @param username
     * @param password
     * @param session
     * @return
     */
    @RequestMapping("/admin/login")
    public View Login(@RequestParam("username") String username, @RequestParam("password") String password, HttpSession session) {

        AdminLoginService adminLoginService = new AdminLoginServiceImpl();

        AdminUser adminUser = adminLoginService.login(username,password);
        System.out.println(password);
        System.out.println(username);
        session.setAttribute("admin",adminUser);

        return new JsonView(success("admin/admin.jsp","登录成功"));
    }



}
